<template>
  <view class="container">
    <!-- 顶部图片 -->
    <image class="article-image" :src="currentArticle.image" mode="aspectFill"></image>

    <!-- 文章标题 -->
    <view class="article-title">{{ currentArticle.title }}</view>

    <!-- 发布时间 -->
    <view class="article-date">发布时间：{{ currentArticle.date }}</view>

    <!-- 正文内容 -->
    <view class="article-detail" v-html="currentArticle.detail"></view>
  </view>
</template>

<script lang="ts" setup>
import { onMounted, computed } from 'vue'
import { useArticleStore } from '@/store/article'

const articleStore = useArticleStore()
const currentArticle = computed(() => articleStore.currentArticle)

onMounted(() => {
  console.log('currentArticle:', currentArticle.value)
})
</script>

<style lang="scss" scoped>
.container {
  padding: 16px;
  background-color: #fff;
}

.article-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  margin-bottom: 16px;
}

.article-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 8px;
}

.article-date {
  font-size: 14px;
  color: #888;
  margin-bottom: 16px;
}

.article-detail {
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap; /* 保留换行 */
}
</style>
